package MyQueue;

import java.util.Stack;

public class test3 {
    private Stack<Integer> stack=new Stack<>();

    private Stack<Integer> stack2=new Stack<>();
    public void push(int x) {
        stack.push(x);
    }

    public int pop() {
        int b;
        while(stack.size()>0){
            int i=stack.pop();
            stack2.push(i);
        }
        Stack<Integer> B=stack;
        stack=stack2;
        stack2=B;
         b=stack.pop();
        while(stack.size()>0){
            int i=stack.pop();
            stack2.push(i);
        }
        Stack<Integer> c=stack;
        stack=stack2;
        stack2=c;
        return b;
    }

    public int peek() {
        int b;
        while(stack.size()>0){
            int i=stack.pop();
            stack2.push(i);
        }
        Stack<Integer> B=stack;
        stack=stack2;
        stack2=B;
        b=stack.peek();
        while(stack.size()>0){
            int i=stack.pop();
            stack2.push(i);
        }
        Stack<Integer> c=stack;
        stack=stack2;
        stack2=c;
        return b;
    }

    public boolean empty() {
        return stack.empty();
    }
}
